package com.photoeditor.demo.ui.activity.setting;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.photoeditor.R;
import com.photoeditor.demo.app.XActivity;
import com.photoeditor.demo.statistics.StatisticsConstant;
import com.photoeditor.demo.statistics.StatisticsUtils;
import com.photoeditor.demo.ui.dialog.NormalDialog;
import com.photoeditor.demo.ui.widget.settings.SettingItem;
import com.photoeditor.demo.util.FontUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by winn on 17/1/15.
 */

public class MoreActivity extends XActivity {
    public static final String TAG = "SettingActivity";

    @Bind(R.id.setting_top)
    View mToolbarView;
    @Bind(R.id.filter_store_top_back)
    ImageView mToolbarBack;
    @Bind(R.id.filter_store_top_name)
    TextView mToolbarTitle;
    //    @Bind(R.id.setting_screen_lock)
//    SettingItem mSettingScreenLock;
//    @Bind(R.id.setting_feedback)
//    SettingItem mSettingFeedback;
//    @Bind(R.id.follow_ins)
//    SettingItem mFollowIns;
    @Bind(R.id.setting_about)
    SettingItem mSettingAbout;


    private NormalDialog mCancelLockScreenMDDialog;

    public static Intent newIntent(Context context) {
        Intent intent = new Intent(context, MoreActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        return intent;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_more);
        ButterKnife.bind(this);

        initView();
    }

    private void initView() {
        // TODO:屏蔽主题
//        StatusBarCompat.setStatusBarColor(this, getResources().getColor(R.color.colorPrimary));
        //StatusBarCompat.setStatusBarColor(this, ThemeManager.getInstance().getResId(getTheme(), R.attr.skin_color_primary));

        mToolbarView.setBackgroundResource(R.drawable.store_top_panel_bg);
        mToolbarBack.setImageResource(R.drawable.icon_back);
        mToolbarTitle.setText(R.string.setting_more);
        mToolbarTitle.setTextColor(getResources().getColor(R.color.title_color));
        FontUtil.setCustomFontBold(mToolbarTitle);

    }


    @Override
    public void onPause() {
        super.onPause();
    }

//    @OnClick(R.id.setting_screen_lock)
//    void onSettingScreenLockClicked() {
//
//        final boolean isChecked = !mSettingScreenLock.isCheck();
//        SettingConfig.getInstance().setScreenLockerModifyByUser(true);
//
//        if (!isChecked) {
//            if (mCancelLockScreenMDDialog == null) {
//                mCancelLockScreenMDDialog = new NormalDialog(this);
//            }
//            mCancelLockScreenMDDialog.setTitleText(getString(R.string.dialog_screen_lock_desc));
//            mCancelLockScreenMDDialog.setTitleTextSize(getResources().getDimensionPixelSize(R.dimen.dimen_16sp));
//            mCancelLockScreenMDDialog.setPositiveBtn(getString(R.string.dialog_screen_lock_no), new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    mCancelLockScreenMDDialog.dismiss();
//                }
//            });
//            mCancelLockScreenMDDialog.setNegativeBtn(getString(R.string.dialog_screen_lock_yes), new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    mCancelLockScreenMDDialog.dismiss();
//                    ThreadPool.runUITask(new Runnable() {
//                        @Override
//                        public void run() {
//                            mSettingScreenLock.setCheck(isChecked);
//                            SettingConfig.getInstance().setOpenLockScreen(isChecked);
////                            BatmobiSDK.setChargeLockSwitch(isChecked);
////                            BatmobiSDK.setScreenLockSwitch(isChecked);
//                        }
//                    }, 200);
//                }
//            });
//            mCancelLockScreenMDDialog.show();
//        } else {
//            mSettingScreenLock.setCheck(isChecked);
//            SettingConfig.getInstance().setOpenLockScreen(isChecked);
////            BatmobiSDK.setChargeLockSwitch(isChecked);
////            BatmobiSDK.setScreenLockSwitch(isChecked);
//        }
//
//
//
//        StatisticsUtils.statisicsCustomSettings(StatisticsConstant.UMENG_CUSTOM_EVENT_SETTINGS_SCREENLOCK_ICON, null);
//    }

//    @OnClick(R.id.setting_feedback)
//    void onSettingFeedbackClicked() {
//        StatisticsUtils.statisicsCustomSettings(StatisticsConstant.UMENG_CUSTOM_EVENT_SETTINGS_FEEDBACK_ICON, null);
//        Feedback.feedback(this);
//    }

//    @OnClick(R.id.follow_ins)
//    void onFollowInsClick() {
//        String id = "potdcam";
//        try{
//            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/_u/" + id));
//            intent.setPackage("com.instagram.android");
//            startActivity(intent);
//        }catch (Exception e){
//            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://instagram.com/" + id)));
//        }
//        StatisticsUtils.statisicsCustomSettings(StatisticsConstant.UMENG_CUSTOM_EVENT_SETTINGS_IG_ICON, null);
//    }

    @OnClick(R.id.setting_about)
    void onSettingAboutClicked() {

        startActivity(AboutActivity.newIntent(this));
        StatisticsUtils.statisicsCustomFunction(StatisticsConstant.UMENG_CUSTOM_EVENT_FUNC_SETTING_MORE_ABOUT_CLICK);
    }

    @OnClick(R.id.filter_store_top_back)
    void onToolbarClick() {
        finish();
    }


    @Override
    public void finish() {
        super.finish();
//        overridePendingTransition(R.anim.activity_close_enter, R.anim.activity_close_exit);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
    }

//    private void updateLockSwitch() {
//        int lockSwitchByStrategy = BatmobiSDK.isLockSwitchByStrategy();
//
//        if (lockSwitchByStrategy == 1) {
//            mSettingScreenLock.setVisibility(View.VISIBLE);
//        } else if (lockSwitchByStrategy == 0 || lockSwitchByStrategy == -1) {
//            mSettingScreenLock.setVisibility(View.GONE);
//        } else if (BatmobiSDK.isBuyUser()) {
//            mSettingScreenLock.setVisibility(View.VISIBLE);
//        } else {
//            mSettingScreenLock.setVisibility(View.GONE);
//        }
//    }
}
